<?php

class Vehicle extends AppModel
{
    var $name = 'Vehicle';
    var $displayField = 'name';
    
    var $hasMany = array('Bookable' =>
                        array('className'    => 'Bookable',
                              'conditions'   => '',
                              'order'        => '',
                              'dependent'    =>  false,
                              'foreignKey'   => 'vehicle_id'
                        )
                  );

    var $hasOne = array( 'Vehicletype' =>
                        array('className'    => 'Vehicletype',
                              'fields'   => 'type',
                              'dependent'    =>  false,
                              'foreignKey' => 'id'
                        )
                  );    

	function beforeValidate(){	
		if ( preg_match( "/^ | \$|\t/"  , $this->data['Vehicle']['acnt_code_gas'] )){
			$this->invalidate('acnt_code_gas');
		}
		//if ( preg_match( "/^[A-Z,a-z,0-9]+$/"  , $this->data['Vehicle']['acnt_code_gas'] )){
		//	$this->invalidate('acnt_code_gas');
		//}		
		
		if ( preg_match( "/^ | \$|\t/"  , $this->data['Vehicle']['acnt_code_admin'])){
			$this->invalidate('acnt_code_admin');
		}	

		if ( preg_match( "/^ | \$|\t/"  , $this->data['Vehicle']['acnt_code_repair'])){
			$this->invalidate('acnt_code_repair');
		}
			
		if ( preg_match( "/^ | \$|\t/"  , $this->data['Vehicle']['acnt_code_insurance'])){
			$this->invalidate('acnt_code_insurance');
		}

		if ( preg_match( "/^ | \$|\t/"  , $this->data['Vehicle']['acnt_code_misc_1'])){
			$this->invalidate('acnt_code_misc_1');
		}
		
		if ( preg_match( "/^ | \$|\t/"  , $this->data['Vehicle']['acnt_code_misc_2'])){
			$this->invalidate('acnt_code_misc_2');
		}

		if ( preg_match( "/^ | \$|\t/"  , $this->data['Vehicle']['acnt_code_misc_3'])){
			$this->invalidate('acnt_code_misc_3');
		}		

		if ( preg_match( "/^ | \$|\t/"  , $this->data['Vehicle']['acnt_code_misc_4'])){
			$this->invalidate('acnt_code_misc_4');
		}	

		if ( preg_match( "/^ | \$|\t/"  , $this->data['Vehicle']['acnt_code_hours'])){
			$this->invalidate('acnt_code_hours');
		}
		
		if ( preg_match( "/^ | \$|\t/"  , $this->data['Vehicle']['acnt_code_blocked_time'])){
			$this->invalidate('acnt_code_blocked_time');
		}

		if ( preg_match( "/^ | \$|\t/"  , $this->data['Vehicle']['acnt_code_km'])){
			$this->invalidate('acnt_code_km');
		}																				
	}
}

?>